package com.ruoyi.web.controller.production.stroma;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import com.ruoyi.production.domain.stroma.StromaPurchaseApply;
import com.ruoyi.production.service.stroma.IStromaPurchaseApplyService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 基质购买申请信息Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/stroma/stromapurchaseApply")
public class StromaPurchaseApplyController extends BaseController
{
    @Autowired
    private IStromaPurchaseApplyService stromaPurchaseApplyService;

    /**
     * 查询基质购买申请信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:stromapurchaseApply:list')")
    @GetMapping("/list")
    public TableDataInfo list(StromaPurchaseApply stromaPurchaseApply)
    {
        startPage();
        List<StromaPurchaseApply> list = stromaPurchaseApplyService.selectStromaPurchaseApplyList(stromaPurchaseApply);
        return getDataTable(list);
    }

    /**
     * 导出基质购买申请信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:stromapurchaseApply:export')")
    @Log(title = "基质购买申请信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StromaPurchaseApply stromaPurchaseApply)
    {
        List<StromaPurchaseApply> list = stromaPurchaseApplyService.selectStromaPurchaseApplyList(stromaPurchaseApply);
        ExcelUtil<StromaPurchaseApply> util = new ExcelUtil<StromaPurchaseApply>(StromaPurchaseApply.class);
        return util.exportExcel(list, "基质购买申请信息数据");
    }

    /**
     * 获取基质购买申请信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:stromapurchaseApply:query')")
    @GetMapping(value = "/{stromaPurchaseApplyId}")
    public AjaxResult getInfo(@PathVariable("stromaPurchaseApplyId") Long stromaPurchaseApplyId)
    {
        return AjaxResult.success(stromaPurchaseApplyService.selectStromaPurchaseApplyById(stromaPurchaseApplyId));
    }

    /**
     * 新增基质购买申请信息
     */
    @PreAuthorize("@ss.hasPermi('system:stromapurchaseApply:add')")
    @Log(title = "基质购买申请信息", businessType = BusinessType.INSERT)
    @PostMapping
    @PropertyInject(type = InjectType.Insert)
    public AjaxResult add(@RequestBody StromaPurchaseApply stromaPurchaseApply)
    {
        return toAjax(stromaPurchaseApplyService.insertStromaPurchaseApply(stromaPurchaseApply));
    }

    /**
     * 修改基质购买申请信息
     */
    @PreAuthorize("@ss.hasAnyPermi('system:stromapurchaseApply:edit,system:stromapurchaseApply:permit')")
    @Log(title = "基质购买申请信息", businessType = BusinessType.UPDATE)
    @PutMapping
    @PropertyInject(type = InjectType.Update)
    public AjaxResult edit(@RequestBody StromaPurchaseApply stromaPurchaseApply)
    {
        return toAjax(stromaPurchaseApplyService.updateStromaPurchaseApply(stromaPurchaseApply));
    }

    /**
     * 删除基质购买申请信息
     */
    @PreAuthorize("@ss.hasPermi('system:stromapurchaseApply:remove')")
    @Log(title = "基质购买申请信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{stromaPurchaseApplyIds}")
    public AjaxResult remove(@PathVariable Long[] stromaPurchaseApplyIds)
    {
        return toAjax(stromaPurchaseApplyService.deleteStromaPurchaseApplyByIds(stromaPurchaseApplyIds));
    }
}
